
#include <vector>
using namespace std;

class Solution
{
public:
    void hanota(vector<int>& A, vector<int>& B, vector<int>& C)
    {
        int n = A.size();
        dfsHano(A, B, C, n);
    }

    void dfsHano(vector<int>& A, vector<int>& B, vector<int>& C, int n)
    {
        if(n==1)
        {
            C.emplace_back(A.back());
            A.pop_back();
            return;
        }

        dfsHano(A, C, B, n-1);
        C.emplace_back(A.back());
        A.pop_back();
        dfsHano(B, A, C, n-1);
    }
};